package ltd.dujiabao.springcloud.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import ltd.dujiabao.springcloud.domain.Order;
import ltd.dujiabao.springcloud.entities.CommonResult;
import ltd.dujiabao.springcloud.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author : DuJiabao
 * @Project : springcloud
 * @Time : 2021/5/26 21:09
 * @Desc :
 */
@Controller
@Slf4j
@Api
public class OrderController {
  @Autowired
  OrderService orderService;

  @PostMapping("/order/create")
  public CommonResult create(@RequestBody Order order) {
    int result = orderService.create(order);
    log.info("result: " + result);
    if (result > 0)
      return new CommonResult(CommonResult.SUCCESS, "订单成功");
    else
      return new CommonResult(CommonResult.FAIlURE, "订单失败");
  }
}
